import 'package:inmotion_pro/config/r.dart';
import 'package:inmotion_pro/l10n/local.dart';
import 'package:inmotion_pro/pages/models/realtime_item.dart';
import 'package:inmotion_pro/service/cache_config_service.dart';

// 主页面常量类
class MainConstant {
  // 速度相关的实时信息Item列表
  static List<RealtimeItemModel> get speedRealtimeItemList => [
        // 当前速速
        RealtimeItemModel.fromMap({})
          ..title = local.current_speed
          ..value = '0'
          ..imgPath = R.speedRealtimeIcon
          ..unit = '${CacheConfigService.to.metricUnit(0).$2}/h'
          ..isEditable = false
          ..isSelected = false,
        // 平均速度
        RealtimeItemModel.fromMap({})
          ..title = local.average_speed
          ..value = '0.0'
          ..imgPath = R.speedAveIcon
          ..unit = '${CacheConfigService.to.metricUnit(0).$2}/h'
          ..isEditable = false
          ..isSelected = false,
        // 最高速度
        RealtimeItemModel.fromMap({})
          ..title = local.max_speed
          ..value = '0.0'
          ..imgPath = R.speedMaxIcon
          ..unit = '${CacheConfigService.to.metricUnit(0).$2}/h'
          ..isEditable = false
          ..isSelected = true
          ..selectedIndex = 2,
        // 动态限速
        RealtimeItemModel.fromMap({})
          ..title = local.speed_limit
          ..value = '0.0'
          ..imgPath = R.speedLimitIcon
          ..unit = '${CacheConfigService.to.metricUnit(0).$2}/h'
          ..isEditable = false
          ..isSelected = false,
      ];

  // 里程Item列表
  static List<RealtimeItemModel> get mileageItemList => [
        // 当前里程
        RealtimeItemModel.fromMap({})
          ..title = local.trip_mileage
          ..value = '0.0'
          ..imgPath = R.tripMileageIcon
          ..unit = CacheConfigService.to.metricUnit(0).$2
          ..isEditable = false
          ..isSelected = true
          ..selectedIndex = 3,
        // 总里程
        RealtimeItemModel.fromMap({})
          ..title = local.total_mileage
          ..value = '0.0'
          ..imgPath = R.totalMileageIcon
          ..unit = CacheConfigService.to.metricUnit(0).$2
          ..isEditable = false
          ..isSelected = true
          ..selectedIndex = 4,
      ];

  // 功率Item列表
  static List<RealtimeItemModel> get powerItemList => [
        // 实时功率
        RealtimeItemModel.fromMap({})
          ..title = local.realtime_power
          ..value = '0.0'
          ..imgPath = R.realtimePowerIcon
          ..unit = "W"
          ..isEditable = false
          ..isSelected = false,
        // 最大功率
        RealtimeItemModel.fromMap({})
          ..title = local.max_power
          ..value = '0.0'
          ..imgPath = R.maxPowerIcon
          ..unit = "W"
          ..isEditable = false
          ..isSelected = false,
        // 平均功率
        RealtimeItemModel.fromMap({})
          ..title = local.average_power
          ..value = '0.0'
          ..imgPath = R.avePowerIcon
          ..unit = "W"
          ..isEditable = false
          ..isSelected = false,
      ];

  // 时长
  static List<RealtimeItemModel> get timeItemList => [
        // 骑行时长
        RealtimeItemModel.fromMap({})
          ..title = local.trip_time
          ..value = '0.0'
          ..imgPath = R.ridingTimeIcon
          ..unit = ''
          ..isEditable = false
          ..isSelected = true
          ..selectedIndex = 1,
        // 开机时长
        RealtimeItemModel.fromMap({})
          ..title = local.up_time
          ..value = '0.0'
          ..imgPath = R.uptimeIcon
          ..unit = ''
          ..isEditable = false
          ..isSelected = false,
      ];

  // 温度
  static List<RealtimeItemModel> tempItemList = [
    // MOS温度
    RealtimeItemModel.fromMap({})
      ..title = local.mos_temperature
      ..value = '0.0'
      ..imgPath = R.mosTemperatureIcon
      ..unit = '℃'
      ..isEditable = false
      ..isSelected = false,
    // 主板温度
    RealtimeItemModel.fromMap({})
      ..title = local.board_temperature
      ..value = '0.0'
      ..imgPath = R.boardTemperatureIcon
      ..unit = '℃'
      ..isEditable = false
      ..isSelected = false,
    // 电机温度
    RealtimeItemModel.fromMap({})
      ..title = local.motor_temperature
      ..value = '0.0'
      ..imgPath = R.motorTemperatureIcon
      ..unit = '℃'
      ..isEditable = false
      ..isSelected = false,
  ];

  // 其他
  static List<RealtimeItemModel> get otherItemList => [
        // 电流
        RealtimeItemModel.fromMap({})
          ..title = local.current_curr
          ..value = '0.0'
          ..imgPath = R.currentIcon
          ..unit = 'A'
          ..isEditable = false
          ..isSelected = false,
        // 电机相电流
        RealtimeItemModel.fromMap({})
          ..title = local.current_iq
          ..value = '0.0'
          ..imgPath = R.currentIcon
          ..unit = 'A'
          ..isEditable = false
          ..isSelected = false,
        // 电压
        RealtimeItemModel.fromMap({})
          ..title = local.voltage
          ..value = '0.0'
          ..imgPath = R.voltageIcon
          ..unit = 'V'
          ..isEditable = false
          ..isSelected = false,
        // 能耗
        RealtimeItemModel.fromMap({})
          ..title = local.power
          ..value = '0.0'
          ..imgPath = R.energyUsageIcon
          ..unit = 'kW'
          ..isEditable = false
          ..isSelected = false,
        // 回收能量
        RealtimeItemModel.fromMap({})
          ..title = local.recovered_energy
          ..value = '0.0'
          ..imgPath = R.energyRecoveryIcon
          ..unit = 'kW'
          ..isEditable = false
          ..isSelected = false,
        // 电机扭矩
        RealtimeItemModel.fromMap({})
          ..title = local.motor_torque
          ..value = '0.0'
          ..imgPath = R.motorTorqueIcon
          ..unit = 'N·m'
          ..isEditable = false
          ..isSelected = false,
        // 输出矢量电压百分比
        RealtimeItemModel.fromMap({})
          ..title = local.output_rate
          ..value = '0.0'
          ..imgPath = R.outputVectorVoltagePercentageIcon
          ..unit = '%'
          ..isEditable = false
          ..isSelected = false,
      ];

  // 所有的实时信息Item列表
  static List<RealtimeItemModel> get totalRealtimeItemList => [
        ...timeItemList,
        ...speedRealtimeItemList,
        ...mileageItemList,
        ...powerItemList,
        ...tempItemList,
        ...otherItemList,
      ];
}
